<% include ../header.ejs %>

<link rel="stylesheet" href="/stylesheets/app/stockpool/stockpoolindex.css">
<script src="/javascripts/app/stockpool/stockpoolindex.js"></script>

<header data-am-widget="header" data-am-sticky class="am-header am-header-default" id="appTemplates-Nav">
    <div class="am-header-left am-header-nav">
        <a href='/smtool_project/wxapp/'>
            <img class="am-header-icon-custom" src="data:image/svg+xml;charset&#x3D;utf-8,&lt;svg xmlns&#x3D;&quot;http://www.w3.org/2000/svg&quot; viewBox&#x3D;&quot;0 0 12 20&quot;&gt;&lt;path d&#x3D;&quot;M10,0l2,2l-8,8l8,8l-2,2L0,10L10,0z&quot; fill&#x3D;&quot;%23fff&quot;/&gt;&lt;/svg&gt;" alt=""/>
        </a>
    </div>

    <h1 class="am-header-title">
        <a href="#title-link" class="" id="Typeface-whitecolor">股票池</a>
    </h1>

    <div class="am-dropdown am-header-right am-header-nav" data-am-dropdown>
        <button class="am-btn am-btn-primary am-dropdown-toggle" data-am-dropdown-toggle>操作&nbsp;<span class="am-icon-caret-down"></span></button>
        <ul class="am-dropdown-content">
            <li>
                <a href="/smtool_project/wxapp/stockpool/<%=personal?'personal':'public'%>/export.xlsx">
                    <div class="am-padding-horizontal-sm">
                        <i class="am-header-icon am-icon-cloud-download"></i>
                        &nbsp;&nbsp;Excel导出
                    </div>
                </a>
            </li>
            <li class="am-divider"></li>
            <% if(userinfo.role=='0'){ %>
            <li>
                <a href="/smtool_project/wxapp/stockpoolgroup">
                    <div class="am-padding-horizontal-sm">
                        <i class="am-header-icon am-icon-edit"></i>
                        &nbsp;&nbsp;分组编辑
                    </div>
                </a>
            </li>
            <li class="am-divider"></li>
            <% } %>
            <li>
                <a href="/smtool_project/wxapp/stockpool/edit">
                    <div class="am-padding-horizontal-sm">
                        <i class="am-header-icon am-icon-plus-square"></i>
                        &nbsp;&nbsp;新建股票
                    </div>
                </a>
            </li>
            <li class="am-divider"></li>
            <li>
                <a href="/smtool_project/wxapp/stockpool/stockpoolindex<%=personal?'':'?createUid='+userinfo.rowId %>">
                    <div class="am-padding-horizontal-sm">
                        <i class="am-header-icon am-icon-line-chart"></i>
                        &nbsp;&nbsp;<%=personal?'默认':'我的'%>股池
                    </div>
                </a>
            </li>
        </ul>
    </div>
</header>

<div data-am-widget="tabs" class="am-tabs am-tabs-default" style="overflow: hidden;">
    <ul class="am-tabs-nav am-cf ullist">
        <li class="am-active"><a href="[data-tab-panel-0]">列表视图</a></li>
        <li><a href="[data-tab-panel-1]">层级视图</a></li>
    </ul>

    <!--listview-->
    <div class="am-tabs-bd">
        <div data-am-widget="list_news" data-tab-panel-0 class="am-tab-panel am-active am-list-news am-list-news-default" style="overflow-y:scroll;">
            <div class="am-list-news-bd">
                <ul class="am-list">
                    <% mconferencelist.forEach(function(data, key){ %>
                    <li onclick="javascript:self.location='../stockpool/stockpooldetail?rowId=<%=data.rowId%>'" class="am-list-item-desced am-list-item-thumbed">
                        <div class="am-list-main">
                            <div class="am-list-item-hd am-g am-div-margin">
                                <a class="am-u-sm-9">
                                    <h3 class="am-list-item-hd">
                                        <% if(data.stockId!=null){ %>
                                        <%= data.stockId.name %> <%= data.stockId.stockCode %>
                                        <%}%>
                                    </h3>
                                </a>
                                <div class="am-u-sm-3 am-fr">
                                    <small class="am-list-item-hd" id="<%=data.rowId%>_0">
                                        <% if(data.stockId!=null){ %>
                                        <script type="text/javascript">
                                            setRealPrice('<%=data.rowId%>','<%=data.stockId.stockCode%>','<%= data.importPrice %>','<%= data.realPrice %>');
                                        </script>
                                        <%}%>
                                    </small>
                                </div>
                            </div>
                            <div class="am-list-item-hd am-g am-div-margin">
                                <div class="am-u-sm-9">
                                    <small class="am-list-item-hd"><%= (data.createUserId && data.createUserId.name) || '' %> 目标价 <%= data.expectPrice %> <%= data.updateTime %></small>
                                </div>
                                <div class="am-u-sm-3 am-fr">
                                    <small class="am-list-item-hd" id="rate<%=data.rowId%>_0"></small>
                                </div>
                            </div>
                        </div>
                    </li>
                    <% }) %>
                </ul>
            </div>
        </div>
        <!--treeview-->
        <div data-tab-panel-1 class="am-tab-panel am-list-news am-list-news-default" style="overflow-y:scroll;">
            <ul class="am-list admin-sidebar-list" id="treeRoot">
                <% tree.forEach(function(parent){//一级股票池
                      var parentNodeName = parent.name;
                      var parentNodeId = parent.id;
                      var children = parent.children || [];
                      var parentList = parent.list || [];%>
                    <li class="am-panel">
                        <a data-am-collapse="{parent: '#treeRoot'
                        <%if (parent.count>0){%>
                           , target: '#<%=parentNodeId%>_1'
                        <%}%>}"><%=parentNodeName%> [<%=parent.count%>]
                            <%if (parent.count>0){%><i class="am-icon-angle-right am-fr am-margin-right"></i><%}%></a>
                    </li>
                <% if (parent.count>0){%>
                    <ul class="am-list am-collapse admin-sidebar-sub" id="<%=parentNodeId%>_1">
                     <%children.forEach(function (child) {//二级股票池
                          var childNodeName = child.name;
                          var childNodeId = child.id;
                          var list = child.list || [];
                          var len = list.length;
                     %>
                          <li class="am-panel children-node">
                                <a data-am-collapse="{parent: '#<%=parentNodeId%>_1'
                            <%if (len>0){%>
                               , target: '#<%=childNodeId%>_1'
                            <%}%>}"><%=childNodeName%> [<%=child.count%>]
                            <%if (child.count>0){%><i class="am-icon-angle-right am-fr am-margin-right"></i><%}%></a>
                          </li>
                          <%if (len>0){%>
                                  <ul class="am-list am-collapse admin-sidebar-sub" id="<%=childNodeId%>_1">
                                      <%list.forEach(function (data) {//股票 %>
                                          <li onclick="javascript:self.location='../stockpool/stockpooldetail?rowId=<%=data.rowId%>'" class="am-list-item-desced am-list-item-thumbed">
                                              <div class="am-list-main">
                                                  <div class="am-list-item-hd am-g am-div-margin">
                                                      <a class="am-u-sm-9">
                                                          <h3 class="am-list-item-hd">
                                                              <% if(data.stockId!=null){ %>
                                                              <%= data.stockId.name %> <%= data.stockId.stockCode %>
                                                              <%}%>
                                                          </h3>
                                                      </a>
                                                      <div class="am-u-sm-3 am-fr">
                                                          <small class="am-list-item-hd" id="<%=data.rowId%>_1">
                                                              <% if(data.stockId!=null){ %>
                                                              <script type="text/javascript">
                                                                  setRealPrice('<%=data.rowId%>','<%=data.stockId.stockCode%>','<%= data.importPrice %>','<%= data.realPrice %>');
                                                              </script>
                                                              <%}%>
                                                          </small>
                                                      </div>
                                                  </div>
                                                  <div class="am-list-item-hd am-g am-div-margin">
                                                      <div class="am-u-sm-9">
                                                          <small class="am-list-item-hd"><%= (data.createUserId && data.createUserId.name) || '' %> 目标价 <%= data.expectPrice %> <%= data.updateTime %></small>
                                                      </div>
                                                      <div class="am-u-sm-3 am-fr">
                                                          <small class="am-list-item-hd" id="rate<%=data.rowId%>_1"></small>
                                                      </div>
                                                  </div>
                                              </div>
                                          </li>
                                      <%});%>
                               </ul>
                          <%}
                      });%>

                     <%if (parentList.length>0){%>
                        <%parentList.forEach(function (data) {//股票%>

                        <li onclick="javascript:self.location='../stockpool/stockpooldetail?rowId=<%=data.rowId%>'" class="am-list-item-desced am-list-item-thumbed">
                            <div class="am-list-main">
                                <div class="am-list-item-hd am-g am-div-margin">
                                    <a class="am-u-sm-9">
                                        <h3 class="am-list-item-hd">
                                            <% if(data.stockId!=null){ %>
                                            <%= data.stockId.name %> <%= data.stockId.stockCode %>
                                            <%}%>
                                        </h3>
                                    </a>
                                    <div class="am-u-sm-3 am-fr">
                                        <small class="am-list-item-hd" id="<%=data.rowId%>_1">
                                            <% if(data.stockId!=null){ %>
                                            <script type="text/javascript">
                                               setRealPrice('<%=data.rowId%>','<%=data.stockId.stockCode%>','<%= data.importPrice %>','<%= data.realPrice %>');
                                            </script>
                                            <%}%>
                                        </small>
                                    </div>
                                </div>
                                <div class="am-list-item-hd am-g am-div-margin">
                                    <div class="am-u-sm-9">
                                        <small class="am-list-item-hd"><%= (data.createUserId && data.createUserId.name) || '' %> 目标价 <%= data.expectPrice %> <%= data.updateTime %></small>
                                    </div>
                                    <div class="am-u-sm-3 am-fr">
                                        <small class="am-list-item-hd " id="rate<%=data.rowId%>_1"></small>
                                    </div>
                                </div>
                            </div>
                        </li>
                        <%});%>
                     <%}%>
                     </ul>
                   <%}%>
                <% }); %>

                <%if (other.length>0){%>
                <%other.forEach(function (data) {//股票%>
                    <li onclick="javascript:self.location='../stockpool/stockpooldetail?rowId=<%=data.rowId%>'" class="am-list-item-desced am-list-item-thumbed">
                        <div class="am-list-main">
                            <div class="am-list-item-hd am-g am-div-margin">
                                <a class="am-u-sm-9">
                                    <h3 class="am-list-item-hd">
                                        <% if(data.stockId!=null){ %>
                                        <%= data.stockId.name %> <%= data.stockId.stockCode %>
                                        <%}%>
                                    </h3>
                                </a>
                                <div class="am-u-sm-3 am-fr">
                                    <small class="am-list-item-hd" id="<%=data.rowId%>_1">
                                        <% if(data.stockId!=null){ %>
                                        <script type="text/javascript">
                                            $(function () {
                                                $.get("/smtool_project/wxapp/api/stock/getRealPrice?stockCode=<%= data.stockId.stockCode%>",function(repdata,status){
                                                    var importPrice = '<%= data.importPrice %>';
                                                    var realRate= getRealRate(importPrice,repdata);

                                                    $('#<%=data.rowId%>').text(toDecimal(realRate)+"%");
                                                    $('#rate<%=data.rowId%>').text(repdata);
                                                });
                                            });
                                        </script>
                                        <%}%>
                                    </small>
                                </div>
                            </div>
                            <div class="am-list-item-hd am-g am-div-margin">
                                <div class="am-u-sm-9">
                                    <small class="am-list-item-hd"><%= (data.createUserId && data.createUserId.name) || '' %> 目标价 <%= data.expectPrice %> <%= data.updateTime %></small>
                                </div>
                                <div class="am-u-sm-3 am-fr">
                                    <small class="am-list-item-hd" id="rate<%=data.rowId%>_1"></small>
                                </div>
                            </div>
                        </div>
                    </li>
                <%});%>
                <%}%>

            </ul>
        </div>
    </div>
</div>

<% include ../footer.ejs %>